﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using haptic.src.engine.render;
using haptic.src.engine.debug;
using haptic.src.engine.collisions;
using LuaInterface;

namespace haptic.src.engine
{
    public class Scene
    {
        #region Edit
        public void RegisterPlayer(Entity oEntity)
        {
            m_oPlayers.Add(oEntity);
        }
        public void UnregisterPlayer(Entity oEntity)
        {
            m_oPlayers.Remove(oEntity);
        }
        #endregion

        #region Load
        public void Load()
        {
            if (m_oCurrentLevel != null)
            {
                m_oCurrentLevel.Load();
            }
        }
        #endregion

        #region Update
        public void Update(GameTime oTime)
        {
            if (m_oCurrentLevel != null)
                m_oCurrentLevel.Update(oTime);
            if (m_oCameraManager != null)
                m_oCameraManager.Update(oTime);
        }
        #endregion

        #region Draw
        public void Draw(Renderer oRenderer, DebugRenderer oDebugRenderer, GameTime oTime)
        {
            if (m_oCurrentLevel != null)
                m_oCurrentLevel.Draw(oRenderer, oTime);

#if DEBUG || RELEASE
            if (oDebugRenderer != null)
                m_oCurrentLevel.DrawDebug(oDebugRenderer, oTime);
#endif
        }
        #endregion

        #region Attributes
        public LevelGraph m_oLevelGraph = new LevelGraph();
        public Level m_oCurrentLevel;
        private List<Entity> m_oPlayers = new List<Entity>();
        public List<Entity> oPlayers { get { return m_oPlayers; } }
        public CollisionManager m_oCollisionManager = new CollisionManager();
        public CameraManager m_oCameraManager = new CameraManager();
        public Lua m_oLua = new Lua();
        #endregion
    }
}
